// /////////////////////////////////////////////////////////////////////////////
//
// Name:            CubePanel.h
// Author:          Michael Bartsch
//
// Desc :           The interface for the CCubePanel class.
//
// License:         Copyright (C) 2008-2009 Michael Bartsch
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the GNU General Public
//                  License as published by the Free Software Foundation,
//                  either version 3 of the License, or (at your option) any
//                  later version.
//
//                  This program is distributed in the hope that it will be
//                  useful, but WITHOUT ANY WARRANTY; without even the implied
//                  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
//                  PURPOSE. See the GNU General Public License for more
//                  details.
//
//                  You should have received a copy of the GNU General Public
//                  License along with this program. If not, see
//                  <http://www.gnu.org/licenses/>.
//
// /////////////////////////////////////////////////////////////////////////////

#ifndef __C_CUBEPANEL_H_INCLUDED__
#define __C_CUBEPANEL_H_INCLUDED__

// Include required header file(s).
#include "../../App.h"

#include "../../../Engine/ColourAnalyser.h"


// Forward Declarations.
class CColourAnalyser;


// The CCubePanel class.
//! This panel displays a 3d analysis of the image.
class CCubePanel : public wxGLCanvas
{
public:

    //! Constructor
    //! @param parent The window parent.
    CCubePanel(wxWindow *parent);

    //! Initialises OpenGL.
    void initGL();

    //! Renders the OpenGL scene.
    void Render();
    //! Creates a RGB-cube in OpenGL.
    void createCube();
    //! Creates the RGB-cloud in OpenGL.
    //! The projected cloud is based upon the latest taken webcam image.
    void createCloud();

    // Event functions.
    //! Handles the paint event.
    void onPaint(wxPaintEvent &event);

    //! Handles the event generated by a left mouse down.
    void onLeftDown(wxMouseEvent &event);
    //! Handles the event generated by a left mouse up.
    void onLeftUp(wxMouseEvent &event);
    //! Handles the event generated by the motion of the mouse.
    void onMouseMotion(wxMouseEvent &event);


private:

    // Internal
    CColourAnalyser *pColourAnalyser;

    // OpenGL
    bool isInitGL;

    float rotateX, rotateY;

    GLuint cubeList;
    GLuint cloudList;

    // Misc.
    bool isLeftDown;
    int clickX, clickY;

    DECLARE_EVENT_TABLE()
};

#endif
